<?php

require '../../src/NonBlocking/Worker.php';

use Snitso\IO\NonBlocking\Worker;

$worker = new Worker('tcp://0.0.0.0:9001');

$worker->onConnect = function (Worker $worker, $conn) {
    echo '有一个连接进来了' . PHP_EOL;
};

$worker->onReceive = function (Worker $worker, $conn, $data) {
    sleep(3);

    var_dump($data);

    $worker->send($conn, 'Hello Baby' . PHP_EOL);
};

$worker->start();